﻿using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using Caliburn.Micro;

namespace ScreenRotateSample.ViewModels
{
    public class Page2ViewModel : Screen
    {
        private readonly INavigationService navigationService;

        #region Collection
        private ObservableCollection<string> items;

        public ObservableCollection<string> Items
        {
            get { return items; }
            set
            {
                items = value;
                NotifyOfPropertyChange(() => Items);
            }
        }

        private string selectedItem;

        public string SelectedItem
        {
            get { return selectedItem; }
            set
            {
                selectedItem = value;
                NotifyOfPropertyChange(() => SelectedItem);
                MessageBox.Show(value);
            }
        }
        #endregion

        public Page2ViewModel(INavigationService navigationService)
        {
            this.navigationService = navigationService;

            Items = new BindableCollection<string>
                {
                    "Value1",
                    "Value2",
                    "Value3"
                };

            DisplayName = "Page2";
        }

        #region ViewEvents
        protected override void OnViewAttached(object view, object context)
        {
            base.OnViewAttached(view, context);
            Debug.WriteLine("OnViewAttached");
        }

        protected override void OnInitialize()
        {
            base.OnInitialize();
            Debug.WriteLine("OnInitialize");
        }

        protected override void OnViewReady(object view)
        {
            base.OnViewReady(view);
            Debug.WriteLine("OnViewReady");
        }

        protected override void OnActivate()
        {
            base.OnActivate();
            Debug.WriteLine("OnActivate:");
        }

        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);
            Debug.WriteLine("OnViewLoaded");
        }

        protected override void OnDeactivate(bool close)
        {
            base.OnDeactivate(close);
            Debug.WriteLine("OnDeactivate");
        }
        #endregion

    }
}
